// formPackage/pages/agencyModule/agencyManagerList/agencyManagerList.js
import { myAgencyCompanyList } from "../../../../service/agency_service"
import { queryCompanyTotalPerformance } from "../../../../service/commission_service"
let app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    themeStyle: "",
    menuTop: app.globalData.menuButton.top,
    menuHeight: app.globalData.menuButton.height,
    switchArr: [
      {
        title: "成员业绩",
        key: "-1",
      },


    ],
    page: 0,
    pageSize: 10,
    topTypeIndex: 0,
    totalData: {

    },
    dataList: [

    ],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

    this.queryCompanyTotalPerformance();
  },


  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    if (app.globalData.themeStyle) {
      this.setData({
        themeStyle: app.globalData.themeStyle
      })
    }
  },
  //顶部切换:
  switchAction(e) {
    let index = e.currentTarget.dataset.index;
    this.setData({
      topTypeIndex: index,
    })
  },

  //查询公司总业绩
  queryCompanyTotalPerformance() {
    wx.showLoading();
    queryCompanyTotalPerformance().then(res => {
      wx.hideLoading();
      console.log("JJLog:获取到的列表是:" + JSON.stringify(res));
      if (res.code == 200) {
        this.setData({
          totalData: res.data,
          dataList: res.data.list || []
        })

      }
    }).catch(err => {
      wx.hideLoading();
      wx.showToast({
        title: err || "查询失败",
        icon: "none"
      })
      console.error("JJLog:queryCompanyTotalPerformance", err);
    })
  },

  //跳转到个人业绩详情:
  pushToDetail(e) {
    let id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '/formPackage/pages/team/personalPerformance/personalPerformance?wxUserId=' + id + "&companyNumber=" + this.data.totalData.companyNumber,
    })
  },







})